#include <iostream>
#include <ctime>
using namespace std;
int n,k;
const int N=5e6+10;
typedef long long LL;
LL a[N];
int get_random(int left,int right)
{
    int p=a[rand()%(right-left+1)+left];
    return p;
}
LL quick_select(int left,int right,int k)
{
    int p=get_random(left,right);
    int l=left-1;int i=left;int r=right+1;
    while(i<r)
    {
        if(a[i]<p)swap(a[++l],a[i++]);
        else if(a[i]==p)i++;
        else swap(a[--r],a[i]);
    }
    int a=l-left+1;int b=r-1-l;int c=right-r+1;
    if(k<=a)return quick_select(left,l,k);
    else if(k<=a+b)return p;
    else if(k>a+b) return quick_select(r,right,k-a-b);
}
int main()
{
    srand(time(0));
    cin>>n>>k;
    k++;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    cout<<quick_select(1,n,k);
    return 0;
}
